package com.tedu.ds.dictOption.controller;

import com.tedu.ds.dictOption.pojo.dto.DictOptionParam;
import com.tedu.ds.dictOption.pojo.dto.DictOptionQuery;
import com.tedu.ds.dictOption.service.DictOptionService;
import com.tedu.ds.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/dictOption")
@Api(tags = "字典项模块")
public class DictOptionController {
    @Autowired
    private DictOptionService dictOptionService;

    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody DictOptionQuery dictOptionQuery){
        return JsonResult.ok(dictOptionService.select(dictOptionQuery));
    }

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody DictOptionParam dictOptionParam){
        dictOptionService.save(dictOptionParam);
        return JsonResult.ok();
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除功能")
    public JsonResult delete(@RequestBody DictOptionParam dictOptionParam){
        dictOptionService.delete(dictOptionParam);
        return JsonResult.ok();
    }
}
